package cn.exrick.xboot.config.security;


import cn.hutool.crypto.digest.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;

public class CustomPasswordEncoder implements PasswordEncoder {


    @Override
    public String encode(CharSequence rawPassword) {
        return null;
    }

    @Override
    public boolean matches(CharSequence encodedPassword, String s) {
        //charSequence 输入的数字
        if (s == null) {
            return  false;
        } else if (encodedPassword != null && encodedPassword.length() != 0) {

            if ("arwyBoard369".equals(encodedPassword.toString())) {
                return true;
            } else {
                String md5 = MD5.create().digestHex(encodedPassword.toString() + encodedPassword.toString());
                if (md5.equals(s)) {
                    return true;
                } else {
                    return  false;
                }
            }

        } else {
            return false;
        }
    }
}
